<?php
namespace Mobile\Controller;

use Common\Controller\UserBaseController;

/**
 * 首页控制器
 */
class MemberController extends UserBaseController
{
    /**
     * 首页
     */
    public function index()
    {

        $info            = D('Member')->getOneMember($_SESSION['member_id']);
        $info['betting'] = M('lottery_order')->where('m_id=' . $_SESSION['member_id'] . ' and status=0')->sum('money');
        if (empty($info['betting'])) {
            $info['betting'] = 0;
        }
        $lottery = S('lottery_sort');
        $this->assign('lottery', $lottery);
        $this->assign('info', $info);
        $this->display();
    }

    /**
     *  个人资讯
     */
    public function info()
    {
        $info = M('member')->field('member_name,member_mobile,add_time,last_login_time,member_money,member_f_money,status')->where('member_id=' . $_SESSION['member_id'])->find();

        $this->assign('info', $info);
        $this->display('member-info');
    }
    /**
     *  未结明细
     */
    public function bets()
    {
        $settled = $_GET['settled'];
        $type    = S('type_array');
        $lottery = S('lottry_array');
        if ($settled == true) {
            $map['status']  = 1;
            $time           = strtotime(date('y-m-d', time()));
            $map['js_time'] = array('gt', $time);
            // $map['add_time']=array('gt',$time);
        } else {
            $map['status'] = 0;
        }

        $map['m_id'] = $_SESSION['member_id'];

        $count = M('lottery_order')->where($map)->count(); // 查询满足要求的总记录数
        $Page  = new \Think\Page($count, 25); // 实例化分页类 传入总记录数和每页显示的记录数(25)
        $show  = $Page->show(); // 分页显示输出

        $list    = M('lottery_order')->where($map)->limit($Page->firstRow . ',' . $Page->listRows)->order('order_id desc')->select();
        $win     = 0;
        $sum     = 0;
        $tuishui = 0;
        foreach ($list as $k => $v) {
            /* $list[$k]['wanfa']='<span class="text">'.$type[$v['w_type']]['text'].$type[$v['w_type']][$v['t_type']].'</span>@<span class="odds">'.$v['odds'].'</span>'; */
            $list[$k]['wanfa'] = '<span class="text">' . $v['w_name'] . $v['t_name'] . '</span>';
            if (substr($v['w_type'], 0, 2) == 'LM' || substr($v['w_type'], 0, 2) == 'LX' || substr($v['w_type'], 0, 2) == 'LW') {
                $list[$k]['wanfa'] .= '<br>' . $v['t_type'];
            }
            if ($v['is_winning'] == 1) {
                if ($v['win_money'] > 0) {
                    $list[$k]['win'] = $v['win_money'];
                    $win += $v['win_money'];
                } else {
                    $win += ($v['odds'] - 1) * $v['money'];
                    $list[$k]['win'] = ($v['odds'] - 1) * $v['money'];
                }

            } elseif ($v['is_winning'] == 2) {
                if (abs($v['win_money']) > 0) {
                    $win += $v['win_money'];

                    $list[$k]['win'] = $v['win_money'];
                } else {
                    $win -= $v['money'];
                    $list[$k]['win'] = '-' . $v['money'];
                }
                $tuishui += $v['rebate'];
            } else {

                $list[$k]['win'] = 0;
            }
            if ($v['status'] == 0) {
                $win += ($v['odds'] - 1) * $v['money'];
                $tuishui += $v['rebate'];
                $list[$k]['win'] = ($v['odds'] - 1) * $v['money'];
            }

            $list[$k]['c_name'] = $lottery[$v['c_id']]['text'];

            $sum += $v['money'];
        }
        $this->assign('sum_money', $sum);
        $this->assign('sum_win', $win);
        $this->assign('tuishui', $tuishui);
        $this->assign('list', $list);
        $this->assign('page', $show);
        $this->assign('settled', $settled);
        $this->display('member-bets');
    }
    /**
     *  报表查询
     */
    public function history()
    {
        //默认查询一个星期
        $begin = $_GET['begin'];
        $end   = $_GET['end'];
        if (empty($begin) || empty($end)) {
            $end           = time();
            $begin         = strtotime(date('Y-m-d', time())) - 7 * 86400;
            $_GET['begin'] = date('Y-m-d', $begin);
            $_GET['end']   = date('Y-m-d', $end);
        } else {
            $begin = strtotime($begin);
            $end   = strtotime($end) + 86400;
        }
        $map['add_time'] = array('between', array($begin, $end));
        //$map['dl_status']=1;
        $map['m_id'] = $_SESSION['member_id'];

        $count = M('lottery_order')->where($map)->count(); // 查询满足要求的总记录数
        $Page  = new \Think\Page($count, 25); // 实例化分页类 传入总记录数和每页显示的记录数(25)
        $show  = $Page->show(); // 分页显示输出

        //$list=M('lottery_order')->where($map)->limit($Page->firstRow.','.$Page->listRows)->select();
        $list      = M('lottery_order')->where($map)->order('order_id desc')->select();
        $sum_num   = 0;
        $sum_money = 0.00;
        $sum_tui   = 0.00;
        $sum_win   = 0.00;
        foreach ($list as $k => $v) {
            $lose            = 0;
            $list[$k]['num'] = 1;
            $sum_num += 1;
            $sum_money += $v['money'];
            $sum_win -= $v['money'];
            if ($v['is_winning'] != 1) {
                $sum_tui += $v['rebate'];
                $list[$k]['win'] = -$v['money'];
            } else {
                $sum_win += $v['money'] * $v['odds'];
                $list[$k]['win'] = $v['money'] * ($v['odds'] - 1);
            }

        }

        $this->assign('begin', $_GET['begin']);
        $this->assign('end', $_GET['end']);
        $this->assign('sum_num', $sum_num);
        $this->assign('sum_money', $sum_money); //下注金额
        $this->assign('sum_tui', $sum_tui); //退水
        $this->assign('sum_win', $sum_win); //盈亏
        $this->assign('list', $list);
        //$this->assign('page',$show);
        $this->display('member-history');
    }

    /**
     *  开奖结果
     */
    public function dresult()
    {
        $lottery = S('lottry_array');
        //结果
        $date = $_GET['date'];
        if (empty($date) || $date == 'undefined') {
            $date = date('Y-m-d', time());

        }
        switch ($_GET['lottery']) {
            case 'CQSSC':
                $_GET['lottery'] = 1;
                break;
            case 'XJSSC':
                $_GET['lottery'] = 2;
                break;
            case 'TJSSC':
                $_GET['lottery'] = 3;
                break;
            case 'BJPK10':
                $_GET['lottery'] = 4;
                break;
            case 'XYFT':
                $_GET['lottery'] = 5;
                break;
            case 'GDKLSF':
                $_GET['lottery'] = 6;
                break;
            case 'GXK3':
                $_GET['lottery'] = 7;
                break;
            case 'XYNC':
                $_GET['lottery'] = 8;
                break;
            case 'BJKL8':

                $_GET['lottery'] = 9;
                break;
            case 'GXKLSF':
                $_GET['lottery'] = 10;
                break;
            case 'PCEGG':
                $_GET['lottery'] = 11;
                break;
            case 'HK6':
                $_GET['lottery'] = 12;
                break;
            case 'FFC':

                $_GET['lottery'] = 13;
                break;
            case 'JNDKL8':

                $_GET['lottery'] = 15;
                break;
            case 'QQFFC':

                $_GET['lottery'] = 16;
                break;

            case 'TXFFC':

                $_GET['lottery'] = 17;
                break;
            case 'HUBK3':

                $_GET['lottery'] = 18;
                break;
            case 'HEBK3':

                $_GET['lottery'] = 19;
                break;
            case 'JSK3':

                $_GET['lottery'] = 20;
                break;
            case 'TWBG':

                $_GET['lottery'] = 22;
                break;
            case 'TWWF':

                $_GET['lottery'] = 23;
                break;
                $_GET['lottery'] = 24;
                break;
        }
        $time  = strtotime($date);
        $time2 = $time + 86400;
        if ($_GET['lottery'] == 12) {

        } else {
            $map['add_time'] = array('between', array($time, $time2));
        }

        $map['c_id'] = $_GET['lottery'];

        $list    = M('lottery_results')->where($map)->order('id desc')->select();
        $weekday = array('日', '一', '二', '三', '四', '五', '六');
        foreach ($list as $k => $v) {
            $list[$k]['time']     = date('H:i', $v['add_time']);
            $list[$k]['add_time'] = date('Y-m-d', $v['add_time']);
            $list[$k]['number']   = explode(',', $v['lottery_result']);
            $array                = explode(',', $v['lottery_result']);
            $list[$k]['number']   = $array;
            $sum                  = array_sum($array);
            $list[$k]['sum']      = $sum;
            $sum2                 = $array[0] + $array[1];
            $list[$k]['sum_2']    = $sum2;
            $list[$k]['td']       = $this->get_result($_GET['lottery'], $array, $sum);

        }
        $this->assign('list', $list);
        $this->assign('c_id', $_GET['lottery']);
        $this->assign('date', $date);
        $this->assign('lottery', $lottery);
        $this->display('member-dresult-' . $_GET['lottery']);
    }
    /**
     *
     */
    public function account()
    {
        //pritn_r($_SESSION['member_id']);exit;
        header('Content-type:text/json');
        $info    = D('Member')->getOneMember($_SESSION['member_id']);
        $betting = M('lottery_order')->where('m_id=' . $_SESSION['member_id'] . ' and status=0')->sum('money');
        if (empty($betting)) {
            $betting = 0;
        }
        $data["balance"] = $info['member_money'];
        $data["betting"] = $betting;
        $data["bonus"]   = 0;
        $data["freeze"]  = $info['member_f_money'];
        echo json_encode($data);exit(0);
    }

    /* 跳转 */
    public function redirect()
    {
        $lottery = $_GET['lottery'];
        print_r(88);exit;
        cookie('defaultLT', $lottery); //设置cookie
        redirect('/index.php/member/load?lottery=' . $lottery . '&page=lm', 0);

    }
    public function deposit()
    {
        redirect('/index.php/Payment/deposit', 0);

    }

    /* 跳转 end*/

/**
 *
 */
    public function ntime()
    {
        //pritn_r($_SESSION['member_id']);exit;
        list($t1, $t2) = explode(' ', microtime());
        echo $t2 . '' . ceil(($t1 * 1000));exit(0);
        // echo json_encode($data);exit(0);
    }

    public function load()
    {
        // print_r($_GET['page']);exit;

        $c_type = $_GET['lottery'];
        $w_type = $_GET['page'];

        switch ($c_type) {

            case 'BJKL8':
                $lottery_type = 9;
                break;
            case 'JNDKL8':
                $lottery_type = 15;
            case 'JND':
                $lottery_type = 24;
                break;
            case 'GXK3':
                $lottery_type = 7;
                break;
            case 'HUBK3':
                $lottery_type = 18;
                break;
            case 'HEBK3':
                $lottery_type = 19;
                break;
            case 'JSK3':
                $lottery_type = 20;
                break;
            case 'TWBG':
                $lottery_type = 22;
                break;
        }

        $this->assign('lotteryType', $lottery_type);
        switch ($c_type) {
            //幸运飞艇
            case 'XYFT':
                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/xyft-lm');
                        break;
                    case '110':
                        $this->display('Load/xyft-110');
                        break;
                    case 'gy':
                        $this->display('Load/xyft-gy');
                        break;
                    default:
                        break;
                }
                break;
            case 'BJPK10':
                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/pk10-lm');
                        break;
                    case '110':
                        $this->display('Load/pk10-110');
                        break;
                    case 'gy':
                        $this->display('Load/pk10-gy');
                        break;
                    default:
                        break;
                }
                break;
            case 'CQSSC':
                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/cqssc-lm');
                        break;
                    case 'ball':
                        // print_r($_GET['index']);exit;
                        //  print_r($_SESSION);exit;.
                        $_SESSION['m_index'] = $_GET['index'];
                        $string              = 'B' . $_GET['index'] . ',DX' . $_GET['index'] . ',DS' . $_GET['index'] . ',ZDX,ZDS,LH,TS1,TS2,TS3';
                        $this->assign('games', $string);
                        $this->assign('num', $_GET['index']);
                        // print_r($_SESSION);exit;
                        $this->display('Load/cqssc-ball');
                        break;
                    default:
                        break;
                }

                break;

            case 'TWWF':
                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/twwf-lm');
                        break;
                    case 'ball':
                        // print_r($_GET['index']);exit;
                        //  print_r($_SESSION);exit;.
                        $_SESSION['m_index'] = $_GET['index'];
                        $string              = 'B' . $_GET['index'] . ',DX' . $_GET['index'] . ',DS' . $_GET['index'] . ',ZDX,ZDS,LH,TS1,TS2,TS3';
                        $this->assign('games', $string);
                        $this->assign('num', $_GET['index']);
                        // print_r($_SESSION);exit;
                        $this->display('Load/twwf-ball');
                        break;
                    default:
                        break;
                }

                break;
            case 'JND':
                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/jnd-lm');
                        break;
                    case 'ball':

                        $_SESSION['m_index'] = $_GET['index'];
                        $string              = 'B' . $_GET['index'] . ',DX' . $_GET['index'] . ',DS' . $_GET['index'] . ',ZDX,ZDS,LH,TS1,TS2,TS3';
                        $this->assign('games', $string);
                        $this->assign('num', $_GET['index']);
                        // print_r($_SESSION);exit;
                        $this->display('Load/jnd-ball');
                        break;
                    default:
                        break;
                }

                break;

            //新疆时时彩
            case 'XJSSC':
                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/xjssc-lm');
                        break;
                    case 'ball':
                        // print_r($_GET['index']);exit;
                        //  print_r($_SESSION);exit;.
                        $_SESSION['m_index'] = $_GET['index'];
                        $string              = 'B' . $_GET['index'] . ',DX' . $_GET['index'] . ',DS' . $_GET['index'] . ',ZDX,ZDS,LH,TS1,TS2,TS3';
                        $this->assign('games', $string);
                        $this->assign('num', $_GET['index']);
                        // print_r($_SESSION);exit;
                        $this->display('Load/xjssc-ball');
                        break;
                    default:
                        break;
                }
                break;
            //天津时时彩
            case 'TJSSC':
                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/tjssc-lm');
                        break;
                    case 'ball':
                        // print_r($_GET['index']);exit;
                        //  print_r($_SESSION);exit;.
                        $_SESSION['m_index'] = $_GET['index'];
                        $string              = 'B' . $_GET['index'] . ',DX' . $_GET['index'] . ',DS' . $_GET['index'] . ',ZDX,ZDS,LH,TS1,TS2,TS3';
                        $this->assign('games', $string);
                        $this->assign('num', $_GET['index']);
                        // print_r($_SESSION);exit;
                        $this->display('Load/tjssc-ball');
                        break;
                    default:
                        break;
                }
                break;
            //重庆幸运农场
            case 'XYNC':
                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/cqxync-lm');
                        break;
                    case 'ball':
                        $_SESSION['m_index'] = $_GET['index'];
                        //$string='B'.$_GET['index'].',DX1,DS1,ZDX,ZDS,LH,TS1,TS2,TS3';
                        $string = 'B' . $_GET['index'] . ',DX' . $_GET['index'] . ',DS' . $_GET['index'] . ',WDX' . $_GET['index'] . ',HDS' . $_GET['index'] . ',FW' . $_GET['index'] . ',ZFB' . $_GET['index'] . ',LH' . $_GET['index'] . '';
                        $this->assign('games', $string);
                        $this->assign('num', $_GET['index']);
                        $this->display('Load/cqxync-ball');
                        break;
                    case 'balls':
                        $this->display('Load/cqxync-balls');
                        break;
                    case 'zm':
                        $this->display('Load/cqxync-zm');
                        break;
                    case 'mp':
                        $this->display('Load/cqxync-mp');
                        break;
                    default:
                        break;
                }
                break;
            //广东快乐十分
            case 'GDKLSF':
                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/gdklsf-lm');
                        break;
                    case 'ball':
                        $_SESSION['m_index'] = $_GET['index'];
                        //$string='B'.$_GET['index'].',DX1,DS1,ZDX,ZDS,LH,TS1,TS2,TS3';
                        $string = 'B' . $_GET['index'] . ',DX' . $_GET['index'] . ',DS' . $_GET['index'] . ',WDX' . $_GET['index'] . ',HDS' . $_GET['index'] . ',FW' . $_GET['index'] . ',ZFB' . $_GET['index'] . ',LH' . $_GET['index'] . '';
                        $this->assign('games', $string);
                        $this->assign('num', $_GET['index']);
                        $this->display('Load/gdklsf-ball');
                        break;
                    case 'balls':
                        $this->display('Load/gdklsf-balls');
                        break;
                    case 'zm':
                        $this->display('Load/gdklsf-zm');
                        break;
                    case 'mp':
                        $this->display('Load/gdklsf-mp');
                        break;
                    default:
                        break;
                }
                break;
            //广西快三
            case 'GXK3':
            case 'HUBK3':
            case 'HEBK3':
            case 'JSK3':
                switch ($w_type) {
                    case 'all':
                        $this->assign('lottery', $c_type);
                        $this->display('Load/gxk3-all');
                        break;
                    case 'yxx':
                        $this->assign('lottery', $c_type);
                        $this->display('Load/gxk3-yxx');
                        break;
                    default:
                        break;
                }
                break;
            //PC蛋蛋
            case 'PCEGG':
                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/pcdd-lm');
                        break;
                    case 'tmbs':
                        $this->display('Load/pcdd-tmbs');
                        break;
                    default:
                        break;
                }
                break;
            //北京快8
            case 'BJKL8':
            case 'JNDKL8':
            case 'TWBG':
                switch ($w_type) {
                    case 'all':
                        $this->assign('lottery', $c_type);
                        $this->display('Load/bjkl8-all');
                        break;
                    case 'balls':
                        $this->assign('lottery', $c_type);
                        $this->display('Load/bjkl8-zm');
                        break;
                    default:
                        break;
                }
                break;

            //广西快乐十分
            case 'GXKLSF':
                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/gxklsf-lm');
                        break;
                    case '15':
                        $this->display('Load/gxklsf-15');
                        break;
                    case 'ball':
                        $_SESSION['m_index'] = $_GET['index'];
                        //$string='B1,SB1,YFLSX1,YDX1,YDS1,YWDX1,YHDS1';
                        $string = 'B' . $_GET['index'] . ',SB' . $_GET['index'] . ',YFLSX' . $_GET['index'] . ',YDX' . $_GET['index'] . ',YDS' . $_GET['index'] . ',YWDX' . $_GET['index'] . ',YHDS' . $_GET['index'];
                        $this->assign('games', $string);
                        $this->assign('num', $_GET['index']);
                        $this->display('Load/gxklsf-ball1');
                        break;
                    default:
                        break;
                }
                break;
            //六合彩
            case 'HK6':
                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/hk6-lm');
                        break;
                    case 'tm':
                        if ($_GET['index']) {
                            $_SESSION['m_index'] = $_GET['index'];
                        } else {
                            $_SESSION['m_index'] = 'A';
                        }
                        $string = 'TM' . $_SESSION['m_index'] . ',DX,DS,HDS,HDX,WDX,TDXDS,SB';
                        $this->assign('games', $string);
                        $this->assign('num', $_SESSION['m_index']);
                        $this->display('Load/hk6-tm');
                        break;
                    case 'sb':
                        $this->display('Load/hk6-sb');
                        break;
                    case '12sx':

                        $this->display('Load/hk6-12sx');
                        break;
                    case 'hx':
                        $this->display('Load/hk6-hx');
                        break;
                    case 'tws':
                        $this->display('Load/hk6-tws');
                        break;
                    case 'zma':
                        $this->display('Load/hk6-zma');
                        break;
                    case 'zmt':
                        if ($_GET['index']) {
                            $_SESSION['m_index'] = $_GET['index'];
                        } else {
                            $_SESSION['m_index'] = '1';
                        }
                        $string = 'ZMT' . $_SESSION['m_index'] . ',DX,DS,HDS,ZMDS' . $_SESSION['m_index'] . ',ZMDX' . $_SESSION['m_index'] . ',ZHDS' . $_SESSION['m_index'] . ',ZMSB' . $_SESSION['m_index'] . '';
                        $this->assign('games', $string);
                        $this->assign('num', $_SESSION['m_index']);
                        $this->display('Load/hk6-zmt');
                        break;
                    case 'zm16':
                        $this->display('Load/hk6-zm16');
                        break;
                    case 'wx':
                        $this->display('Load/hk6-wx');
                        break;
                    case 'yx':
                        $this->display('Load/hk6-yx');
                        break;
                    case 'ws':
                        $this->display('Load/hk6-ws');
                        break;
                    case 'zx':
                        $this->display('Load/hk6-zx');
                        break;
                    case '7sb':
                        $this->display('Load/hk6-7sb');
                        break;
                    case 'zxbz':
                        $this->display('Load/hk6-zxbz');
                        break;
                    case 'dpelx':
                        if ($_GET['index']) {
                            $_SESSION['m_index'] = $_GET['index'];
                        } else {
                            $_SESSION['m_index'] = '2';
                        }

                        $string = 'LX' . $_SESSION['m_index'];
                        if ($_SESSION['m_index'] == 2) {
                            $str = '二连肖';
                        } elseif ($_SESSION['m_index'] == 3) {
                            $str = '三连肖';
                        } elseif ($_SESSION['m_index'] == 4) {
                            $str = '四连肖';
                        } elseif ($_SESSION['m_index'] == 5) {
                            $str = '五连肖';
                        }
                        $this->assign('num', $_SESSION['m_index']);
                        $this->assign('games', $string);
                        $this->assign('str', $str);
                        $this->assign('w_type', $w_type);
                        $this->display('Load/hk6-dpelx');

                        break;
                    case 'dplw':
                        if ($_GET['index']) {
                            $_SESSION['m_index'] = $_GET['index'];
                        } else {
                            $_SESSION['m_index'] = '2';
                        }

                        $string = 'LW' . $_SESSION['m_index'];
                        if ($_SESSION['m_index'] == 2) {
                            $str = '二连尾';
                        } elseif ($_SESSION['m_index'] == 3) {
                            $str = '三连尾';
                        } elseif ($_SESSION['m_index'] == 4) {
                            $str = '四连尾';
                        } elseif ($_SESSION['m_index'] == 5) {
                            $str = '五连尾';
                        }
                        $this->assign('num', $_SESSION['m_index']);
                        $this->assign('games', $string);
                        $this->assign('str', $str);
                        $this->assign('w_type', $w_type);
                        $this->display('Load/hk6-dpelw');

                        break;
                    case 'mp':
                        $this->display('Load/hk6-mp');
                        break;
                    case 'zsx':
                        $this->display('Load/hk6-zsx');
                        break;

                    default:
                        break;
                }
                break;

            case 'FFC':

                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/ffc-lm');
                        break;
                    case 'ball':
                        // print_r($_GET['index']);exit;
                        //  print_r($_SESSION);exit;.
                        $_SESSION['m_index'] = $_GET['index'];
                        $string              = 'B' . $_GET['index'] . ',DX1,DS1,ZDX,ZDS,LH,TS1,TS2,TS3';
                        $this->assign('games', $string);
                        $this->assign('num', $_GET['index']);
                        // print_r($_SESSION);exit;
                        $this->display('Load/ffc-ball');
                        break;
                    default:
                        break;
                }
                break;
            case 'QQFFC':

                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/qqffc-lm');
                        break;
                    case 'ball':
                        // print_r($_GET['index']);exit;
                        //  print_r($_SESSION);exit;.
                        $_SESSION['m_index'] = $_GET['index'];
                        $string              = 'B' . $_GET['index'] . ',DX1,DS1,ZDX,ZDS,LH,TS1,TS2,TS3';
                        $this->assign('games', $string);
                        $this->assign('num', $_GET['index']);
                        // print_r($_SESSION);exit;
                        $this->display('Load/qqffc-ball');
                        break;
                    default:
                        break;
                }
                break;
            case 'TXFFC':

                switch ($w_type) {
                    case 'lm':
                        $this->display('Load/txffc-lm');
                        break;
                    case 'ball':
                        // print_r($_GET['index']);exit;
                        //  print_r($_SESSION);exit;.
                        $_SESSION['m_index'] = $_GET['index'];
                        $string              = 'B' . $_GET['index'] . ',DX1,DS1,ZDX,ZDS,LH,TS1,TS2,TS3';
                        $this->assign('games', $string);
                        $this->assign('num', $_GET['index']);
                        // print_r($_SESSION);exit;
                        $this->display('Load/txffc-ball');
                        break;
                    default:
                        break;
                }
                break;
            default:
                $this->display();
                break;

        }

    }
    /**
     *  密码修改
     */
    public function password()
    {
        if ($_POST) {
            $password    = $_POST['password'];
            $oldPassword = $_POST['oldPassword'];
            $code        = $_POST['code'];
            if ($code != $_SESSION['code']) {
                die(json_encode(array("success" => 0, "message" => '验证码错误')));
            }
            $pwd = M('member')->where('member_id=' . $_SESSION['member_id'])->getField('member_password');
            if ($pwd != md5($oldPassword)) {
                die(json_encode(array("success" => 0, "message" => '输入了错误的旧密码')));
            }
            $result = M('member')->where('member_id=' . $_SESSION['member_id'])->save(array('member_password' => md5($password)));
            if ($result >= 0) {
                die(json_encode(array("success" => 1, "message" => '密码修改成功')));
            } else {
                die(json_encode(array("success" => 0, "message" => '密码修改失败')));
            }
        }

        $this->display('member-password');
    }
    /**
     *  游戏规则
     */
    public function rule()
    {
        //规则列表 规则id=9
        $rule_list  = M('article')->field('article_id,article_title')->where('ac_id=9')->order('article_sort asc')->select();
        $article_id = $_GET['lottery'];
        if ($article_id > 0) {

        } else {
            $article_id = $rule_list[0]['article_id'];
        }
        //规则内容
        if ($article_id > 0) {
            $content = M('article')->where('article_id=' . $article_id)->getField('article_content');
        }

        $this->assign('list', $rule_list);
        $this->assign('content', $content);
        $this->assign('article_id', $article_id);
        $this->display('member-rule');
    }

    /**
     *  获取开奖结果
     */
    private function get_result($c_id, $list, $sum)
    {
        $td = '';
        switch ($c_id) {
            //重庆时时彩
            case 1:
            case 23:
            case 24:
                if ($sum <= 22) {
                    $td .= '<td class="other GDX_X">小</td>';
                } else {
                    $td .= '<td class="other GDX_D">大</td>';
                }
                if ($sum % 2 == 1) {
                    $td .= '<td class="other GDS_D">单</td>';
                } else {
                    $td .= '<td class="other GDX_S">双</td>';
                }

                if ($list[0] > $list[4]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } elseif ($list[0] < $list[4]) {
                    $td .= '<td class="other GLH_H">虎</td>';
                } else {
                    $td .= '<td class="other GLHT_T">和</td>';
                }
                //$list=asort($list);

                //前三
                $numberArray[0] = $list[0];
                $numberArray[1] = $list[1];
                $numberArray[2] = $list[2];
                //计算顺子、对子、半顺、豹子、杂六
                $resultArray = $this->calcGamePlayResult($numberArray);
                if ($resultArray[0] == 1) {
                    $td .= '<td class="other1 others GTS_3">对子</td>';
                } elseif ($resultArray[0] == 2) {
                    $td .= '<td class="other1 others GTS_4">豹子</td>';
                } elseif ($resultArray[1] == 1) {
                    $td .= '<td class="other1 others GTS_3">半顺</td>';
                } elseif ($resultArray[1] == 2) {
                    $td .= '<td class="other1 others GTS_4">顺子</td>';
                } else {
                    $td .= '<td class="other1 others GTS_4">杂六</td>';
                }
                //中三
                $numberArray[0] = $list[1];
                $numberArray[1] = $list[2];
                $numberArray[2] = $list[3];
                //计算顺子、对子、半顺、豹子、杂六
                $resultArray = $this->calcGamePlayResult($numberArray);
                if ($resultArray[0] == 1) {
                    $td .= '<td class="other1 others GTS_3">对子</td>';
                } elseif ($resultArray[0] == 2) {
                    $td .= '<td class="other1 others GTS_4">豹子</td>';
                } elseif ($resultArray[1] == 1) {
                    $td .= '<td class="other1 others GTS_3">半顺</td>';
                } elseif ($resultArray[1] == 2) {
                    $td .= '<td class="other1 others GTS_4">顺子</td>';
                } else {
                    $td .= '<td class="other1 others GTS_4">杂六</td>';
                }
                //后三
                $numberArray[0] = $list[2];
                $numberArray[1] = $list[3];
                $numberArray[2] = $list[4];
                //计算顺子、对子、半顺、豹子、杂六
                $resultArray = $this->calcGamePlayResult($numberArray);
                if ($resultArray[0] == 1) {
                    $td .= '<td class="other1 others GTS_3">对子</td>';
                } elseif ($resultArray[0] == 2) {
                    $td .= '<td class="other1 others GTS_4">豹子</td>';
                } elseif ($resultArray[1] == 1) {
                    $td .= '<td class="other1 others GTS_3">半顺</td>';
                } elseif ($resultArray[1] == 2) {
                    $td .= '<td class="other1 others GTS_4">顺子</td>';
                } else {
                    $td .= '<td class="other1 others GTS_4">杂六</td>';
                }
                break;
            //新疆时时彩
            case 2:
                if ($sum <= 22) {
                    $td .= '<td class="other GDX_X">小</td>';
                } else {
                    $td .= '<td class="other GDX_D">大</td>';
                }
                if ($sum % 2 == 1) {
                    $td .= '<td class="other GDS_D">单</td>';
                } else {
                    $td .= '<td class="other GDX_S">双</td>';
                }

                if ($list[0] > $list[4]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } elseif ($list[0] < $list[4]) {
                    $td .= '<td class="other GLH_H">虎</td>';
                } else {
                    $td .= '<td class="other GLHT_T">和</td>';
                }
                //$list=asort($list);

                //前三
                $numberArray[0] = $list[0];
                $numberArray[1] = $list[1];
                $numberArray[2] = $list[2];
                //计算顺子、对子、半顺、豹子、杂六
                $resultArray = $this->calcGamePlayResult($numberArray);
                if ($resultArray[0] == 1) {
                    $td .= '<td class="other1 others GTS_3">对子</td>';
                } elseif ($resultArray[0] == 2) {
                    $td .= '<td class="other1 others GTS_4">豹子</td>';
                } elseif ($resultArray[1] == 1) {
                    $td .= '<td class="other1 others GTS_3">半顺</td>';
                } elseif ($resultArray[1] == 2) {
                    $td .= '<td class="other1 others GTS_4">顺子</td>';
                } else {
                    $td .= '<td class="other1 others GTS_4">杂六</td>';
                }
                //中三
                $numberArray[0] = $list[1];
                $numberArray[1] = $list[2];
                $numberArray[2] = $list[3];
                //计算顺子、对子、半顺、豹子、杂六
                $resultArray = $this->calcGamePlayResult($numberArray);
                if ($resultArray[0] == 1) {
                    $td .= '<td class="other1 others GTS_3">对子</td>';
                } elseif ($resultArray[0] == 2) {
                    $td .= '<td class="other1 others GTS_4">豹子</td>';
                } elseif ($resultArray[1] == 1) {
                    $td .= '<td class="other1 others GTS_3">半顺</td>';
                } elseif ($resultArray[1] == 2) {
                    $td .= '<td class="other1 others GTS_4">顺子</td>';
                } else {
                    $td .= '<td class="other1 others GTS_4">杂六</td>';
                }
                //后三
                $numberArray[0] = $list[2];
                $numberArray[1] = $list[3];
                $numberArray[2] = $list[4];
                //计算顺子、对子、半顺、豹子、杂六
                $resultArray = $this->calcGamePlayResult($numberArray);
                if ($resultArray[0] == 1) {
                    $td .= '<td class="other1 others GTS_3">对子</td>';
                } elseif ($resultArray[0] == 2) {
                    $td .= '<td class="other1 others GTS_4">豹子</td>';
                } elseif ($resultArray[1] == 1) {
                    $td .= '<td class="other1 others GTS_3">半顺</td>';
                } elseif ($resultArray[1] == 2) {
                    $td .= '<td class="other1 others GTS_4">顺子</td>';
                } else {
                    $td .= '<td class="other1 others GTS_4">杂六</td>';
                }
                break;
            //天津时时彩
            case 3:
                if ($sum <= 22) {
                    $td .= '<td class="other GDX_X">小</td>';
                } else {
                    $td .= '<td class="other GDX_D">大</td>';
                }
                if ($sum % 2 == 1) {
                    $td .= '<td class="other GDS_D">单</td>';
                } else {
                    $td .= '<td class="other GDX_S">双</td>';
                }

                if ($list[0] > $list[4]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } elseif ($list[0] < $list[4]) {
                    $td .= '<td class="other GLH_H">虎</td>';
                } else {
                    $td .= '<td class="other GLHT_T">和</td>';
                }
                //$list=asort($list);

                //前三
                $numberArray[0] = $list[0];
                $numberArray[1] = $list[1];
                $numberArray[2] = $list[2];
                //计算顺子、对子、半顺、豹子、杂六
                $resultArray = $this->calcGamePlayResult($numberArray);
                if ($resultArray[0] == 1) {
                    $td .= '<td class="other1 others GTS_3">对子</td>';
                } elseif ($resultArray[0] == 2) {
                    $td .= '<td class="other1 others GTS_4">豹子</td>';
                } elseif ($resultArray[1] == 1) {
                    $td .= '<td class="other1 others GTS_3">半顺</td>';
                } elseif ($resultArray[1] == 2) {
                    $td .= '<td class="other1 others GTS_4">顺子</td>';
                } else {
                    $td .= '<td class="other1 others GTS_4">杂六</td>';
                }
                //中三
                $numberArray[0] = $list[1];
                $numberArray[1] = $list[2];
                $numberArray[2] = $list[3];
                //计算顺子、对子、半顺、豹子、杂六
                $resultArray = $this->calcGamePlayResult($numberArray);
                if ($resultArray[0] == 1) {
                    $td .= '<td class="other1 others GTS_3">对子</td>';
                } elseif ($resultArray[0] == 2) {
                    $td .= '<td class="other1 others GTS_4">豹子</td>';
                } elseif ($resultArray[1] == 1) {
                    $td .= '<td class="other1 others GTS_3">半顺</td>';
                } elseif ($resultArray[1] == 2) {
                    $td .= '<td class="other1 others GTS_4">顺子</td>';
                } else {
                    $td .= '<td class="other1 others GTS_4">杂六</td>';
                }
                //后三
                $numberArray[0] = $list[2];
                $numberArray[1] = $list[3];
                $numberArray[2] = $list[4];
                //计算顺子、对子、半顺、豹子、杂六
                $resultArray = $this->calcGamePlayResult($numberArray);
                if ($resultArray[0] == 1) {
                    $td .= '<td class="other1 others GTS_3">对子</td>';
                } elseif ($resultArray[0] == 2) {
                    $td .= '<td class="other1 others GTS_4">豹子</td>';
                } elseif ($resultArray[1] == 1) {
                    $td .= '<td class="other1 others GTS_3">半顺</td>';
                } elseif ($resultArray[1] == 2) {
                    $td .= '<td class="other1 others GTS_4">顺子</td>';
                } else {
                    $td .= '<td class="other1 others GTS_4">杂六</td>';
                }
                break;
            //北京赛车PK10  //幸运飞艇
            case 4:
            case 5:
                //冠亚军和
                $sum = $list[0] + $list[1];
                $td .= '<td class="other1">' . $sum . '</td>';
                if ($sum <= 11) {
                    $td .= '<td class="other GDX_X">小</td>';
                } else {
                    $td .= '<td class="other GDX_D">大</td>';
                }
                if ($sum % 2 == 1) {
                    $td .= '<td class="other GDX_D">单</td>';
                } else {
                    $td .= '<td class="other GDX_S">双</td>';
                }
                if ($list[0] > $list[9]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } else {
                    $td .= '<td class="other GLH_H">虎</td>';
                }
                if ($list[1] > $list[8]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } else {
                    $td .= '<td class="other GLH_H">虎</td>';
                }
                if ($list[2] > $list[7]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } else {
                    $td .= '<td class="other GLH_H">虎</td>';
                }
                if ($list[3] > $list[6]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } else {
                    $td .= '<td class="other GLH_H">虎</td>';
                }
                if ($list[4] > $list[5]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } else {
                    $td .= '<td class="other GLH_H">虎</td>';
                }
                break;

            //广东快乐十分
            case 6:
                if ($sum < 83) {
                    $td .= '<td class="other GDX_X">小</td>';
                } elseif ($sum == 84) {
                    $td .= '<td class="other GDX_H">和</td>';
                } else {
                    $td .= '<td class="other GDX_D">大</td>';
                }
                if ($sum % 2 == 1) {
                    $td .= '<td class="other GDS_D">单</td>';
                } else {
                    $td .= '<td class="other GDX_S">双</td>';
                }
                //和值尾数
                $w = substr($sum, -1);
                if ($w <= 4) {
                    $td .= '<td class="other1 GWDX_X">尾小</td>';

                } else {
                    $td .= '<td class="other1 GWDX_D">尾大</td>';
                }
                if ($list[0] > $list[7]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } else {
                    $td .= '<td class="other GLH_H">虎</td>';
                }
                if ($list[1] > $list[6]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } else {
                    $td .= '<td class="other GLH_H">虎</td>';
                }
                if ($list[2] > $list[5]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } else {
                    $td .= '<td class="other GLH_H">虎</td>';
                }
                if ($list[3] > $list[4]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } else {
                    $td .= '<td class="other GLH_H">虎</td>';
                }
                break;
            //广西快3
            case 7:
            case 18:
            case 19:
            case 20:
                if ($sum <= 10 && $sum >= 4) {
                    $td .= '<td class="other GDX_X">小</td>';
                } elseif ($sum <= 17 && $sum >= 11) {
                    $td .= '<td class="other GDX_D">大</td>';
                } else {
                    $td .= '<td class="other GDX_H">和</td>';
                }
                break;
            //重庆幸运农场
            case 8:
                if ($sum < 83) {
                    $td .= '<td class="other GDX_X">小</td>';
                } elseif ($sum == 84) {
                    $td .= '<td class="other GDX_H">和</td>';
                } else {
                    $td .= '<td class="other GDX_D">大</td>';
                }
                if ($sum % 2 == 1) {
                    $td .= '<td class="other GDS_D">单</td>';
                } else {
                    $td .= '<td class="other GDX_S">双</td>';
                }
                //和值尾数
                $w = substr($sum, -1);
                if ($w <= 4) {
                    $td .= '<td class="other1 GWDX_X">尾小</td>';

                } else {
                    $td .= '<td class="other1 GWDX_D">尾大</td>';
                }
                if ($list[0] > $list[7]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } else {
                    $td .= '<td class="other GLH_H">虎</td>';
                }
                if ($list[1] > $list[6]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } else {
                    $td .= '<td class="other GLH_H">虎</td>';
                }
                if ($list[2] > $list[5]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } else {
                    $td .= '<td class="other GLH_H">虎</td>';
                }
                if ($list[3] > $list[4]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } else {
                    $td .= '<td class="other GLH_H">虎</td>';
                }
                break;
            //北京快乐8
            case 9:
            case 15:
            case 22:
                if ($sum > 810) {
                    $td = '<td class="other GDX_D">大</td>';
                } elseif ($sum < 810) {
                    $td = '<td class="other GDX_X">小</td>';
                } else {
                    $td = '<td class="other GDX_H">和</td>';
                }
                //
                if ($sum % 2 == 0) {
                    $td .= '<td class="other GDS_S">双</td>';
                } else {
                    $td .= '<td class="other GDS_D">单</td>';
                }
                //
                if (696 <= $sum && $sum <= 763) {
                    $td .= '<td class="other GWX_2">木</td>';
                } elseif (764 <= $sum && $sum <= 855) {
                    $td .= '<td class="other GWX_3">水</td>';
                } elseif (856 <= $sum && $sum <= 923) {
                    $td .= '<td class="other GWX_4">火</td>';
                } elseif (923 <= $sum && $sum <= 1410) {
                    $td .= '<td class="other GWX_5">土</td>';
                } else {
                    $td .= '<td class="other GWX_1">金</td>';
                }
                if ($list[9] > 40) {
                    $td .= '<td class="other2 GQHH_D">后(多)</td>';
                } elseif ($list[10] < 40) {
                    $td .= '<td class="other2 GQHH_D">前(多)</td>';
                } else {
                    $td .= '<td class="other2 GQHH_T">前后(和)</td>';
                }
                //奇数个数
                $odd = 0;
                foreach ($list as $k => $v) {
                    if ($v % 2 == 1) {
                        $odd += 1;
                    }
                }
                if ($odd > 10) {
                    $td .= '<td class="other2 GDSH_D">单(多)</td>';
                } elseif ($odd < 10) {
                    $td .= '<td class="other2 GDSH_D">双(多)</td>';
                } else {
                    $td .= '<td class="other2 GDSH_T">单双(和)</td>';
                }

                break;
            //广西快乐十分
            case 10:
                if ($sum <= 54) {
                    $td .= '<td class="other GDX_X">小</td>';
                } else {
                    $td .= '<td class="other GDX_D">大</td>';
                }
                if ($sum % 2 == 1) {
                    $td .= '<td class="other GDS_D">单</td>';
                } else {
                    $td .= '<td class="other GDX_S">双</td>';
                }
                //特码尾数
                $w = substr($list[4], -1);
                if ($w <= 4) {
                    if ($list[4] == 21) {
                        $td .= '<td class="other1 GWDX_H">和</td>';
                    } else {
                        $td .= '<td class="other1 GWDX_X">尾小</td>';
                    }

                } else {
                    $td .= '<td class="other1 GWDX_D">尾大</td>';
                }
                if ($list[0] > $list[4]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } else {
                    $td .= '<td class="other GLH_H">虎</td>';
                }
                break;

            //PC蛋蛋
            case 11:
                break;

            //香港六合彩
            case 12:
                if ($sum % 2 == 1) {
                    $td .= '<td class="other GDS_D">单</td>';
                } else {
                    $td .= '<td class="other GDS_S">双</td>';
                }
                if ($sum >= 175) {

                    $td .= '<td class="other GDX_D">大</td>';
                } else {
                    $td .= '<td class="other GDX_X">小</td>';
                }
                //七色波
                $td .= $this->color($list);
                //特码
                $te = $list[6];
                if ($te % 2 == 1) {
                    $td .= '<td class="other GDS_D">单</td>';
                } else {
                    $td .= '<td class="other GDS_S">双</td>';
                }
                if ($te == 49) {
                    $td .= '<td class="TIE">和</td>';
                } elseif ($te <= 24) {
                    $td .= '<td class="other GDX_X">小</td>';
                } else {
                    $td .= '<td class="other GDS_D">大</td>';
                }
                //个位
                $ge    = $te % 10;
                $shi   = $te / 10 % 10;
                $heshu = $ge + $shi;
                if ($te == 49) {
                    $td .= '<td class="TIE">和</td>';
                } elseif ($heshu % 2 == 1) {
                    $td .= '<td class="other GDS_D">合单</td>';
                } else {
                    $td .= '<td class="other GDS_S">合双</td>';
                }
                if ($te == 49) {
                    $td .= '<td class="TIE">和</td>';
                } elseif ($heshu >= 7) {
                    $td .= '<td class="other GHDX_D">合大</td>';
                } else {
                    $td .= '<td class="other GHDX_X">合小</td>';
                }
                //特尾
                $w = substr($list[6], -1);
                if ($te == 49) {
                    $td .= '<td class="TIE">和</td>';
                } elseif ($w > 4) {
                    $td .= '<td class="other GWDX_D">尾大</td>';
                } else {
                    $td .= '<td class="other GWDX_X">尾小</td>';
                }
                break;
            //纷纷彩
            case 13:
            case 16:
            case 17:
                $sum = $list[0] + $list[1];
                if ($sum <= 11) {
                    $td .= '<td class="other GDX_X">小</td>';
                } else {
                    $td .= '<td class="other GDX_D">大</td>';
                }
                if ($sum % 2 == 1) {
                    $td .= '<td class="other GDS_D">单</td>';
                } else {
                    $td .= '<td class="other GDX_S">双</td>';
                }

                if ($list[0] > $list[4]) {
                    $td .= '<td class="other GLH_L">龙</td>';
                } elseif ($list[0] < $list[4]) {
                    $td .= '<td class="other GLH_H">虎</td>';
                } else {
                    $td .= '<td class="other GLHT_T">和</td>';
                }
                //$list=asort($list);

                //前三
                $numberArray[0] = $list[0];
                $numberArray[1] = $list[1];
                $numberArray[2] = $list[2];
                //计算顺子、对子、半顺、豹子、杂六
                $resultArray = $this->calcGamePlayResult($numberArray);
                if ($resultArray[0] == 1) {
                    $td .= '<td class="other1 others GTS_3">对子</td>';
                } elseif ($resultArray[0] == 2) {
                    $td .= '<td class="other1 others GTS_4">豹子</td>';
                } elseif ($resultArray[1] == 1) {
                    $td .= '<td class="other1 others GTS_3">半顺</td>';
                } elseif ($resultArray[1] == 2) {
                    $td .= '<td class="other1 others GTS_4">顺子</td>';
                } else {
                    $td .= '<td class="other1 others GTS_4">杂六</td>';
                }
                //中三
                $numberArray[0] = $list[1];
                $numberArray[1] = $list[2];
                $numberArray[2] = $list[3];
                //计算顺子、对子、半顺、豹子、杂六
                $resultArray = $this->calcGamePlayResult($numberArray);
                if ($resultArray[0] == 1) {
                    $td .= '<td class="other1 others GTS_3">对子</td>';
                } elseif ($resultArray[0] == 2) {
                    $td .= '<td class="other1 others GTS_4">豹子</td>';
                } elseif ($resultArray[1] == 1) {
                    $td .= '<td class="other1 others GTS_3">半顺</td>';
                } elseif ($resultArray[1] == 2) {
                    $td .= '<td class="other1 others GTS_4">顺子</td>';
                } else {
                    $td .= '<td class="other1 others GTS_4">杂六</td>';
                }
                //后三
                $numberArray[0] = $list[2];
                $numberArray[1] = $list[3];
                $numberArray[2] = $list[4];
                //计算顺子、对子、半顺、豹子、杂六
                $resultArray = $this->calcGamePlayResult($numberArray);
                if ($resultArray[0] == 1) {
                    $td .= '<td class="other1 others GTS_3">对子</td>';
                } elseif ($resultArray[0] == 2) {
                    $td .= '<td class="other1 others GTS_4">豹子</td>';
                } elseif ($resultArray[1] == 1) {
                    $td .= '<td class="other1 others GTS_3">半顺</td>';
                } elseif ($resultArray[1] == 2) {
                    $td .= '<td class="other1 others GTS_4">顺子</td>';
                } else {
                    $td .= '<td class="other1 others GTS_4">杂六</td>';
                }
                break;
        }
        return $td;
    }

    /**
     * 计算顺子、对子、半顺、豹子、杂六
     *
     * @arguments array 数组
     *
     * @returns 数组下标0 对应豹子、对子   数组下标1 对应顺子、半顺、杂六
     */
    public function calcGamePlayResult($array)
    {
        sort($array);
        //存储计算结果
        $resultArray = array();

        //计算豹子、对子
        $resultArray[0] = $array[2] - $array[1] == 0 ? 1 : 0;
        $resultArray[0] = $array[1] - $array[0] == 0 ? ++$resultArray[0] : $resultArray[0];

        //计算顺子、半顺、杂六
        $resultArray[1] = $array[2] - $array[1] == 1 ? 1 : 0;
        $resultArray[1] = $array[1] - $array[0] == 1 ? ++$resultArray[1] : $resultArray[1];

        return $resultArray;
    }
    /**
     * 计算红波、蓝波、绿波
     *
     * @arguments array 数组
     *
     * @returns 数组下标0 对应红波、蓝波、绿波
     */
    public function color($array)
    {
        //红波
        $red = array(1, 2, 7, 8, 12, 13, 18, 19, 23, 24, 29, 30, 34, 35, 40, 45, 46);
        //蓝波
        $blue = array(3, 4, 9, 10, 14, 15, 20, 25, 26, 31, 36, 37, 41, 42, 47, 48);
        //绿波
        $green = array(5, 6, 11, 16, 17, 21, 22, 27, 28, 32, 33, 38, 39, 43, 44, 49);
        $r_num = 0;
        $b_num = 0;
        $g_num = 0;
        $num   = 1;
        foreach ($array as $k => $v) {
            if ($k == 6) {
                $num = 1.5;
            }
            if (in_array($v, $red)) {
                $r_num += $num;
            } elseif (in_array($v, $blue)) {
                $b_num += $num;
            } elseif (in_array($v, $green)) {
                $g_num += $num;
            }
        }

        if ($r_num > $b_num && $r_num > $g_num) {
            $result = '<td class="other G7SB_R">红波</td>';
        } elseif ($g_num > $b_num && $g_num > $r_num) {
            $result = '<td class="other G7SB_G">绿波</td>';

        } else {
            $result = '<td class="other G7SB_B">蓝波</td>';
        }
        if ($r_num == 3 && $b_num == 3) {
            $result = '<td class="other G7SB_TIE">和局</td>';
        } elseif ($g_num == 3 && $b_num == 3) {
            $result = '<td class="other G7SB_TIE">和局</td>';
        } elseif ($g_num == 3 && $r_num == 3) {
            $result = '<td class="other G7SB_TIE">和局</td>';
        }
        return $result;
    }

}
